package com.lixiang.userinfo.service.impl;

import java.util.HashMap;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lixiang.userinfo.dao.SalesmanMapper;
import com.lixiang.userinfo.entity.Salesman;
import com.lixiang.userinfo.service.ISalesmanService;
/**
 * 销售业务层实现类
 * @author 李湘
 * @date 2018-10-19
 */
@Service
public class SalesmanServiceImpl implements ISalesmanService {

	@Autowired
	private SalesmanMapper salesmanMapper;//自动注入依赖
	
	/**
	 * 分页查询销售信息
	 * @param page
	 * @param map
	 * @return
	 */
	public PageInfo<Salesman> selectAll(int page, HashMap<String, Object> map) {
		//设置分页
		PageHelper.startPage(page, 10);
		PageHelper.orderBy(" sale_id desc");
		//查询数据
		List<Salesman> salesList=salesmanMapper.selectAll(map);
		//封装
		PageInfo<Salesman> pageInfo=new PageInfo<Salesman>(salesList);
		return pageInfo;
	}

	/**
     * 添加销售信息
     * @param record 销售对象
     * @return 影响行数
     */
	public int insertSelective(Salesman record) {
		return salesmanMapper.insertSelective(record);
	}

	/**
     * 删除销售信息 将状态置为2 禁用
     * @param saleId
     * @return 影响行数
     */
	public int delete(Integer saleId) {
		return salesmanMapper.delete(saleId);
	}

	/**
     * 更新编辑销售信息
     * @param record
     * @return
     */
	public int updateByPrimaryKeySelective(Salesman record) {
		return salesmanMapper.updateByPrimaryKeySelective(record);
	}

}
